<template>
  <div id="Table">
    <v-table
      :pageSize="pageSize"
      :page="page"
      :searchFlag="false"
      :tableConfig="tableConfig"
      :tableData="tableData"
      :total="total"
      @findData="getTableData"
      @getTableData="getTableData"
      @selectData="setSelectData"
      @setdialog="setdialog"
      @upData="getTableData"
      ref="table"
    ></v-table>
  </div>
</template>

<script>
import table from "commons/Table";
import baseMixin from "@/mixins/BaseMixin";

export default {
  name: "Table",
  mixins: [baseMixin],
  props: {
    data: {
      type: Object
    }
  },
  data () {
    return {
      tableConfig: [
        {
          label: this.$t('outbound.stepnumber'),
          prop: "stepnumber",
        },
        {
          label: this.$t('outbound.userlinenumber'),
          prop: "allocatestrategylinenumber"
        },
        {
          label: this.$t('common.desc'),
          prop: "descr",
        },
        {
          label: this.$t('config.measureUnit'),
          prop: "uomdescr",
          input: "select",
          options: this.getOptions('querycodeLkup/TMUOM')
        },
        {
          label: this.$t('outbound.pickcode'),
          prop: "pickcode",
        },
        {
          label: this.$t('outbound.locallocationsort'),
          prop: "locallocationsortdescr",
        },
        {
          label: this.$t('outbound.locationcategoryoverride'),
          prop: "locationcategoryoverride",
        },
        {
          label: this.$t('outbound.groupuompicks'),
          prop: "groupuompicksdescr",
          input: "select",
          options: this.getOptions('querycodeLkup/YESNO')
        },
        {
          label: this.$t('outbound.locationtypeoverride'),
          prop: "locationtypeoverride",
        },
        {
          label: this.$t('outbound.locationtypeoverridestripe'),
          prop: "locationtypeoverridestripe",
          input: "select",
          options: this.getOptions('querycodeLkup/YESNO')
        },
      ],
      tableData: [],
      page: 1,
      pageSize: 10,
      total: 10,
    }
  },
  methods: {
    //获取table数据
    async getTableData (page, data) {
      try {
        this.loading = true;
        let res = await this.$api.get(`/queryallocatestrategydetail/${this.data.argument.allocatestrategykey}/${page}/${this.$store.state.wms}`);
        
          this.tableData = res.page.list;
          this.$store.commit("setTemporary", this.tableData);
          this.pageSize = res.page.pageSize;
          this.page = res.page.curpage;
          this.total = res.page.total;
        
      } catch (e) {
        this.$message.error(e);
      } finally {
        this.loading = false;
      }

    },
    //选中的数据
    setSelectData (data) {
      this.$parent.selectData = data;
    },
    //进入详情
    async setdialog (data) {
      this.$parent.enterDetails(data);
    },
  },
  mounted () {
    this.getTableData(1)
  },
  components: {
    "v-table": table
  }
}
</script>

<style scoped>
</style>
